package cn.schoolwow.quickdao.test.module.business.user.operation;

import cn.schoolwow.quickdao.domain.DAO;
import cn.schoolwow.quickdao.domain.database.parent.DatabaseType;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;

public class ReinitializeDatabaseTestCaseFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        DAO dao = flowContext.checkInstanceData(DAO.class);
        DatabaseType databaseType = flowContext.checkInstanceData(DatabaseType.class);

        switch (databaseType){
            case SQLite:{
                flowContext.brokenCurrentFlow("SQLite数据库不支持重新初始化");
            }break;
            default:{
                dao.clearEntityTable();
                dao.initialDatabase();
            }
        }
    }

    @Override
    public String name() {
        return "重新初始化数据库";
    }
}
